/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sirtet.tetris.gui;

import java.awt.BorderLayout;
import javax.swing.JPanel;

/**
 * A TetrisBoard visualizer
 * @author guangwei.zhu
 */
public class TetrisGamePanel extends JPanel {

    public TetrisGamePanel(TetrisBoardPanel boardPanel, NextPiecePanel nextPiecePanel) {
        // Set the underlying TetrisBoard
        this.boardPanel = boardPanel;
        this.nextPiecePanel = nextPiecePanel;

        // Initialize the children components
        initComponents();
    }

    /**
     * This method initializes the layout of this Panel.  This is not a NetBeans
     * generated function.
     */
    protected void initComponents() {
        // We use a BorderLayout for the component
        BorderLayout layout = new BorderLayout();
        this.setLayout(layout);

        layout.setHgap(5);

        // Add content panel at the center
        this.add(boardPanel, BorderLayout.CENTER);

        // Add NextPiecePanel and put it on the left (by default)
        this.add(nextPiecePanel, BorderLayout.WEST);

        boardPanel.getBoard().addBoardListener(nextPiecePanel);
    }

    private NextPiecePanel nextPiecePanel;
    private TetrisBoardPanel boardPanel;
}

